<?php
// +----------------------------------------------------------------------
// | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 听雨 < 389625819@qq.com >
// +----------------------------------------------------------------------


namespace app\admin\controller;

use \think\Db;
use app\admin\controller\Permissions;
class Seo extends Permissions
{
    public function index()
    {
        $seo = Db::name('seo')->select();
        $this->assign('seo',$seo);
        // var_dump($news);
        return $this->fetch();
    }

    /**
     * 添加招聘信息
     */
    public function add(){

        //判断是不是操作数据库  
        if($this->request->isPost()){

            $post=$this->request->Post();
            $data=[
                    'title'=>$post['title'],
                    'key'=>$post['key'],
                    'dec'=>$post['dec'],
                ];
            $id=$this->request->Post("id");

                $res = Db::name("seo")->where("id",$id)->update($data);
                if($res==false) return $this->error('修改失败');     
            return $this->success("信息保存成功",'admin/seo/index');
        }elseif(Request()->has("id")){
            $id=Request()->param("id");
            $seo = Db::name("seo")->where("id",$id)->find();
            $this->assign("seo",$seo);
            return $this->fetch();
        }
    }

}
